Processing device and related products

ABSTRACT

A pooling operation method and a processing device for performing the same are provided. The pooling operation method may rearrange a dimension order of the input data before pooling is performed. The technical solutions provided by the present disclosure have the advantages of short operation time and low energy consumption.

CROSS REFERENCE TO RELATED APPLICATION

The present application is a continuation application of U.S.application Ser. No. 16/168,778, filed on Oct. 23, 2018, which is acontinuation application of International Application No.PCT/CN2017/099991, filed Aug. 31, 2017, both of which are incorporatedherein by reference in their entireties.

TECHNICAL FIELD

The present disclosure relates to the field of communication and chiptechnology, and particularly relates to a processing device and relatedproducts for performing pooling operations.

BACKGROUND

Artificial neural networks (ANN) have been a research hotspot promptedsince the 1980s. An ANN abstracts human brain neural networks from theperspective of information processing to establish a simple model andform different networks according to different connection modes. It isalso often referred to as a neural network or a neural-like network inengineering and academia. A neural network is an operation modelconsisting of a larger number of interconnected nodes (or neurons).Operations of the existing neural networks are performed based on acentral processing unit (CPU) or a graphic processing unit (GPU), andthe operations consume high power and long operation time.

SUMMARY

The embodiments of the present disclosure provide a method foroperations in a neural network and related products, which can reduceoperation time and decrease power consumption of the module,

According to a first aspect of the present disclosure, a processingdevice is disclosed. The processing device includes a main processingcircuit and a plurality of basic processing circuits. The main unit isconfigured to receive input data. The input data is four-dimensionaldata is arranged in dimensions N, C, H, and W, wherein dimension C isbetween an outermost layer and an innermost layer of the input data. Themain processing circuit is further configured to rearrange the inputdata such that dimension C becomes the innermost layer, and perform apooling operation on the rearranged input data.

According to a second aspect of the present disclosure, a poolingoperation method performed by a processing device is disclosed. Themethod includes receiving, by the processing device, input data. Theinput data is four-dimensional data is arranged in dimensions N, C, H,and W, wherein dimension C is between an outermost layer and aninnermost layer of the input data. The method further includesrearranging, by the processing device, the input data such thatdimension C becomes the innermost layer of the input data. The methodalso includes performing, by the processing device, a pooling operationon the input data.

The embodiments of the present disclosure have the following beneficialeffects. In the embodiments of the present disclosure, the input data isrearranged to have a different dimension order, and then poolingoperations are performed on the rearranged data. In this way, thecalculation time is reduced and power consumption of the processingdevice is saved.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1a is a schematic structural diagram of a processing deviceaccording to one embodiment of the present disclosure.

FIG. 1b is a schematic structural diagram of another processing deviceaccording to one embodiment of the present disclosure.

FIG. 1c is a schematic diagram illustrating data distribution in aprocessing device according to one embodiment of the present disclosure.

FIG. 1d is a schematic diagram illustrating data return in a processingdevice according to one embodiment of the present disclosure.

FIG. 2a is a flow chart illustrating a method for performing operationsof a neural network according to one embodiment of the presentdisclosure.

FIG. 2b is a schematic diagram illustrating a multiplication operationbetween a matrix A and a matrix B according to one embodiment of thepresent disclosure.

FIG. 3 is a flow chart illustrating another method for performingoperations of a neural network according to one embodiment of thepresent disclosure.

FIG. 4a is a schematic diagram illustrating single-sample input data ofa fully connected layer.

FIG. 4b is a schematic diagram illustrating multiple-sample input dataof a fully connected layer.

FIG. 4c is a schematic diagram illustrating M convolution kernels of anexemplary convolution.

FIG. 4d is a schematic diagram illustrating input data of an exemplaryconvolution.

FIG. 4e is a schematic diagram illustrating a sliding operation windowof a three-dimensional data block of input data.

FIG. 4f is a schematic diagram illustration another sliding operationwindow of a three-dimensional data block of input data.

FIG. 4g is a schematic diagram illustration yet another slidingoperation window of a three-dimensional data block of input data.

DETAILED DESCRIPTION

Technical solutions in the embodiments of the present disclosure will bedescribed clearly and completely hereinafter with reference to theaccompanying drawings in the embodiments of the present disclosure.Apparently, the described embodiments are merely some rather than allembodiments of the present disclosure. All other embodiments obtained bythose of ordinary skill in the art based on the embodiments of thepresent disclosure without creative efforts shall fall within theprotection scope of the present disclosure.

The terms such as “first”, “second”, “third”, and “fourth” used in thespecification, the claims, and the accompanying drawings of the presentdisclosure are used for distinguishing between different objects ratherthan describing a particular order. The terms “include” and “comprise”as well as variations thereof are intended to cover non-exclusiveinclusion. For example, a process, method, system, product, device, orapparatus including a series of steps or units is not limited to thelisted steps or units, it can optionally include other steps or unitsthat are not listed; alternatively, other steps or units inherent to theprocess, method, product, or device can be included either.

The term “embodiment” referred to herein means that a particularfeature, structure, or feature described in conjunction with theembodiment may be contained in at least one embodiment of the presentdisclosure. The phrase appearing in various places in the specificationdoes not necessarily refer to the same embodiment, nor does it refer toan independent or alternative embodiment that is mutually exclusive withother embodiments. It is expressly and implicitly understood by thoseskilled in the art that an embodiment described herein may be combinedwith other embodiments.

The following describes a CPU as an example to illustrate an operationin a neural network. Matrix multiplication is widely used in the neuralnetwork, and in the embodiments of the present disclosure, amultiplication of a matrix A and a matrix B is described as an exampleto illustrate an AND operation in the CPU. Assuming that amultiplication result of the matrix A and the matrix B is a matrix C,i.e., C=A*B, the multiplication operation is illustrated below.

$C = {\begin{bmatrix}a_{11} & a_{12} & a_{13} \\a_{21} & a_{22} & a_{23} \\a_{31} & a_{32} & a_{33}\end{bmatrix}*\begin{bmatrix}b_{11} & b_{12} & b_{13} \\b_{21} & b_{22} & b_{23} \\b_{31} & b_{32} & b_{33}\end{bmatrix}}$

For the CPU, the matrix C can be calculated as follows. Multiplicationcalculation may be sequentially performed for the first line, the secondline, and the third line, in other words, after the multiplicationcalculation for a line is completed, the multiplication calculation foranother line can be performed. Taking the above formula as an example,the multiplication calculation for the first line is first performed andcompleted, by the CPU, to obtain results of a₁₁*b₁₁+a₁₂*b₂₁+a₁₃*b₃₁,a₁₁*b₁₂+a₁₂*b₂₂+a₁₃*b₃₂, and a₁₁*b₁₃+a₁₂*b₂₃+a₁₃*b₃₃, and then themultiplication calculation for the second line is performed andcompleted to obtain results of a₂₁*b₁₁+a₂₂*b₂₁+a₂₃*b₃₁,a₂₁*b₁₂+a₂₂*b₂₂+a₂₃*b₃₂, and a₂₁*b₁₃+a₂₂*b₂₃+a₂₃*b₃₃, and themultiplication calculation for the third line is finally performed andcompleted to obtain results of a₃₁*b₁₁+a₃₂*b₂₁+a₃₃*b₃₁,a₃₁*b₁₂+a₃₂*b₂₂+a₃₃*b₃₂, and a₃₁*b₁₃+a₃₂*b₂₃+a₃₃*b₃₃.

Therefore, for a CPU or a GPU, it needs to perform calculations line byline, that is, after a calculation operation for the first line iscompleted, a calculation operation for the second line is performed, andthen a calculation operation for the third line is performed untilcalculation operations for all lines has been completed. A neuralnetwork may include thousands of rows to be calculated, such that acalculation operation for the neural network may cost a long period oftime. During the calculation operation for the neural network, the CPUis constantly in operation state with high energy consumption.

FIG. 1a is a schematic structural diagram of a processing device 100.Consistent with this disclosure, a “processing device” may beinterchangeably referred as a “chip device.” Processing device 100includes a main unit 101 and a plurality of basic units 102, and mainunit 101 is connected to the plurality of basic units 102 respectively.Referring to a structure illustrated in FIG. 1a , since each of thebasic units is directly and physically connected with the main unit, thenumber of basic units connected to the structure is limited, which issuitable for simple data calculation only. In some embodiments, bothmain unit 101 and basic units 102 are hardware units. For example, mainunit 101 may be a main processing circuit and basic units 102 may bebasic processing circuits.

FIG. 1b is a schematic structural diagram of a processing device 110. Asillustrated in FIG. 1b , the processing device includes main unit 111, aplurality of basic units 112, and branch units 113. Main unit 111 andbasic units 112 are similar to main unit 101 and basic units 102. Branchunits 113 are also hardware units, such as branch processing circuits.Main unit 111 may include at least one of a register and an on-chipcache circuit, and may further include a vector arithmetic unit circuit,an arithmetic and logic unit (ALU) circuit, an accumulator circuit, anda direct memory access (DMA) circuit, in practical applications, mainunit 111 may further include a conversion circuit (for example, a matrixtransposition circuit), a data rearrangement circuit, an activationcircuit, and the like.

Each of basic units 112 may include at least one of a basic register anda basic on-chip cache circuit, and may further include one or anycombination of an inner-product arithmetic unit circuit, a vectorarithmetic unit circuit, an accumulator circuit, and the like. Each ofthe above-mentioned circuits can be an integrated circuit. In anembodiment, the processing device is provided with branch units 112,main unit 111 is coupled with branch units 113, and each of branch units113 is connected to a corresponding basic unit 112. Basic unit 112 isconfigured to perform an inner-product operation between data blocks.Main unit 111 is configured to receive and transmit external data, andto distribute the external data to branch units 113. Branch unit 113 isconfigured to receive and transmit data from main unit 111 or basic unit112. The structure of the processing device illustrated in FIG. 1b isapplicable for calculations of complex data. Since the number of unitsconnected to main unit 111 is limited, it is necessary to add branchunits 113 between main unit 111 and basic units 112 to provide accessesfor more basic units 112, so as to achieve calculations of complex datablocks.

Branch unit 113 and basic unit 112 may be connected by any type ofconnection structure, which is not limited to an H-type structureillustrated in FIG. 1b . In one embodiment, data from the main unit maybe broadcasted or distributed to basic units 112 and data from a basicunit 112 may be gathered to main unit 111. That is, data may betransmitted in a broadcast manner, a distribution manner, and a gathermanner, which are described in detail as follows.

A data transfer manner of main unit 111 to basic unit 112 may includethe follows.

In one embodiment, main unit 111 is connected with multiple branch units112 respectively, and each of branch units 112 is connected withmultiple basic units respectively.

In another embodiment, main unit 111 is connected with a branch unit112, and branch unit 112 is connected with another branch unit 112.Accordingly, multiple branch units 112 are connected in series, andthen, each of the multiple branch units 112 is connected with multiplebasic units 112 respectively.

In yet another embodiment, main unit 111 is connected with each ofmultiple basic units 112 respectively, and each branch unit 113 isconnected in series with multiple basic units 112.

In still another embodiment, main unit 111 is connected with a branchunit 113, and branch unit 113 is connected with another branch unit 113.Accordingly, multiple branch units 113 are connected in series, andthen, each of the multiple branch units 113 is connected with multiplebasic units 112 in series.

When distributing data, the main unit transmits data to some or all ofbasic units 112 and data received by each of basic units 112 may bedifferent.

When broadcasting data, the main unit transmits data to some or all ofbasic units 112, and data received by each of basic units 112 is thesame.

When gathering data, some or all of basic units 112 transmit data to themain unit. It should be noted that processing device 100/110 illustratedin FIG. 1a or FIG. 1b may be a single physical chip. In practicalapplications, the processing device may also be integrated in anotherchip (such as a CPU, a GPU). The specific embodiments in the presentdisclosure do not limit the physical representation of theabove-mentioned processing device.

FIG. 1c is a schematic diagram illustrating data distribution of aprocessing device 110. As illustrated by arrows in FIG. 1c , the arrowsindicate a distribution direction of the data. As illustrated in FIG. 1c, after receiving external data, the external data is split anddistributed, by main unit 111, to multiple branch units 113, and thenthe multiple branch units 113 transmit the data split to basic units112.

FIG. 1d is a schematic diagram illustrating data return of a processingdevice 110. As illustrated by arrows in FIG 1d , which indicate a returnpath of the data. As illustrated in FIG. 1d , basic units 112 returndata (for example, an inner-product operation result) to branch units113, and then branch units 113 return the data to main unit 111.

As illustrated in FIG. 2a , a method for operations in a neural networkby using the above-mentioned processing device is provided. The methodis implemented by using a processing device illustrated in FIG. 1a orFIG. 1b . As illustrated in FIG. 2a , the method includes the following.

At S201, the main unit of the processing device may acquire a data blockto-be-calculated and an operation instruction.

The data block to-be-calculated at S201 may be a matrix, a vector, athree-dimensional data, a four-dimensional data, a multi-dimensionaldata, and the like. The form of the data block to-be-calculated is notlimited in the embodiments of the present disclosure. The operationinstruction may be a multiplication instruction, a convolutioninstruction, an addition instruction, a subtraction instruction, a BasicLinear Algebra Subprograms (BLAS) function, an activation function, orthe like.

At S202, the main unit may divide the data block to-be-calculated into adistribution data block and a broadcast data block according to theoperation instruction.

The S202 may be implemented as follows.

When the operation instruction is a multiplication instruction, amultiplier data block is determined to be the broadcast data block, anda multiplicand data block is determined to be the distribution datablock.

When the operation instruction is a convolution instruction, an inputdata block is determined to be the broadcast data block, and aconvolution kernel is determined to be the distribution data block.

Operations at S203 may include operations at S2031 and S2032.

At S2031, the main unit may split the distribution data block intomultiple basic data blocks, and distribute the basic data blocks to themultiple basic units.

At S2032, the main unit may broadcast the broadcast data block to themultiple basic units.

In one embodiment, the operations at S2031 and S2032 may also beperformed cyclically. In a case that there is a large amount ofdata-to-be-calculated, the main unit may split the distribution datablock into multiple basic data blocks and split each of the multiplebasic data blocks into m basic data sub-blocks, and split the broadcastdata block into m broadcast data sub-blocks. The main unit maydistribute one basic data sub-block of each basic data block andbroadcast one broadcast data sub-block each time. The basic datasub-block and the broadcast data sub-block are data blocks capable ofperforming parallel neural network computations. Take a multiplicationof a matrix B of size 1000*1000 and a matrix A of size 1000*1000 as anexample. A basic data block may be z^(th) row data of the matrix A, anda basic data sub-block may be the first 20 columns of data in the z^(th)row data of the matrix A, the broadcast data sub-block may be the first20 rows of data in the z^(th) column data of matrix B.

The basic data block at S203 may be a minimum data block capable ofperforming an inner-product operation. In a matrix multiplication, forexample, the basic data block may be a row of data of a matrix. Forexample, in a convolution operation, the basic data block may be theweight of a convolution kernel.

A manner for distributing data blocks at S203 may refer to thedescription of the following embodiments, and details are not describedherein again. The reference of a manner for broadcasting the broadcastdata block may be made in the description of the following embodiments,and details are not described herein again.

Operations at S204 may include operations of S2041 and S2042.

At S2041, the basic unit of the processing device may perform aninner-product operation on the basic data block and the broadcast datablock to obtain an operation result (alternatively, may obtain anintermediate result).

At S2042, when the operation result is not an intermediate result, theoperation result may be transmitted to the main unit in a return manner.

The return manner at S204 may refer to the description of the followingembodiments, and details are not described herein again.

At S205, the main unit may obtain the instruction result correspondingto the data blocks to-be-calculated and the operation instruction byprocessing the operation result.

A processing manner at S205 may be an accumulation operation, a sortalgorithm, or the like. The present disclosure is not limited to aspecific processing manner. The specific processing manner needs to beconfigured according to different operation instructions, for example,may also include a nonlinear transformation or the like.

In technical solutions provided by the present disclosure, whenperforming an operation, the main unit may perform the followingoperations. External data including a data block to-be-calculated and anoperation instruction may be received, and the data blockto-be-calculated and the operation instruction may then be acquired. Adistribution data block and a broadcast data block of the data blockto-be-calculated may be determined according to the operationinstruction. The distribution data block may be split into multiplebasic data blocks. The broadcast data block may broadcast to themultiple basic units. The multiple basic data blocks may be distributedto the multiple basic units. The multiple basic units may respectivelyperform inner-product operations for the multiple basic data blocks andthe broadcast data block to obtain operation results, and return theoperation results to the main unit. The main unit obtains theinstruction result of the operation instruction according to theoperation results returned. The technical point of this technicalsolution can be illustrated as follows. For a neural network,inner-product operations between data blocks need large amounts ofcalculations, resulting in a larger computational overhead and a longerperiod of calculation time. Therefore, the embodiments of the presentdisclosure first distinguish a distribution data block and a broadcastdata block in data blocks to-be-calculated according to an operationinstruction and the data blocks to-be-calculated. The broadcast datablock is a data block that must be used when implementing aninner-product operation, and the distribution data block can be split inthe inner-product operation. Taking a matrix multiplication as anexample, the data block to-be-calculated may include a matrix A and amatrix B. An operation instruction can be a multiplication instruction(A*B). According to the rule of matrix multiplication, the matrix A isdetermined as the distribution data block subject to split, and thematrix B is determined as the broadcast data block. For the matrixmultiplication, the multiplicand matrix A can be split into multiplebasic data blocks, and the multiplier matrix B can be a broadcast datablock. According to the definition of the matrix multiplication, data ofeach line of the multiplicand matrix A is subject to inner-productoperations with the multiplier matrix B. Therefore, in technicalsolutions of the present application, the matrix A may be divided into Mbasic data blocks, and each of the M basic data blocks may be a row ofdata of the matrix A. Thus, for matrix multiplication, a time-consumingoperation is performed by multiple basic units individually, such thatin an inner-product operation, the multiple basic units can quicklycalculate the operation results in parallel to reduce calculation time.In addition, less calculation time can also reduce the operating timeduration of the processing device, thereby reducing power consumption.

The effects of the technical solutions provided by the presentdisclosure will be described below by practical examples. FIG. 2b is aschematic diagram illustrating a multiplication operation for a matrix Aand a vector B. As illustrated in FIG. 2b , the matrix A has M rows andL columns, the vector B has L rows. Assume that a time duration requiredfor the inner-product operation of one row of the matrix A and thevector B is t1. When a CPU or a GPU is employed to perform operations,only after a calculation operation for a line is completed, acalculation operation can be performed for another. Therefore, a timeduration T0 of a calculation operation for the above-mentioned matrix Aand the vector B by a GPU or a CPU will be M*t1. With technicalsolutions provided by the embodiments of the present disclosure, assumethat the number of basic units is M, the matrix A will be split into Mbasic data blocks, and each basic data block can be a row of data of thematrix A. The M basic units can simultaneously perform inner-productoperations in parallel, and then the calculation time duration is t1. Inthe technical solutions provided by the embodiments of the presentdisclosure, the time duration required T1 can be a sum of t1, t2, andt3, where t2 is a time duration required for the main unit to splitdata, and t3 is a time duration required for processing the operationresults of the inner-product operations to obtain an instruction result.The calculation amount required for splitting data and processingoperation results are very small, and therefore, the time consumption isvery small, that is, T0>>T1, and the total calculation time duration canbe significant reduced in the technical solutions of the embodiments ofthe present disclosure. Moreover, as for the power consumption generatedduring processing the data to-be-calculated, the operating time durationof processing device provided by the present disclosure can beparticularly short due to T0>>T1. Experiments have illustrated that whenthe operating time duration of the processing device is very short, theenergy consumption will be much lower than the energy consumption oflong operating time duration, thereby reducing energy consumption.

In the foregoing operations at S203, the main unit may broadcast thebroadcast data block to the multiple basic units in multipleimplementation manners, which may specifically be described as follows.

In a method A, the broadcast data block is broadcast to multiple basicunits by one time. The term “broadcast” refers to performing“one-to-many” data transmission, that is, the main unit simultaneouslysends the same data block to multiple (all or part of) basic units. Forexample, in a matrix multiplication between a matrix A and a matrix B,where the matrix B is implemented as a broadcast data block, the matrixB will be broadcast to the multiple basic units. For another example, ina convolution operation, the input data block is implemented as abroadcast data block, and the input data block will be broadcast tomultiple basic units at one time. The advantage of the method A is thatdata transmission amount between the main unit and the multiple basicunits can be saved by transmitting all the broadcast data to multiplebasic units via only one broadcast.

In a method B, the broadcast data block is divided into multiplebroadcast data sub-blocks, and the multiple broadcast data sub-blockswill be broadcast to multiple basic units by multiple times. Forexample, the matrix B may be broadcast to the multiple basic units bymultiple times. Specifically, each N columns of data of the matrix B maybe broadcast each time. The advantage of the method B is thatconfiguration requirements of the multiple basic units can be decreased.Normally, a storage space of a register of a basic unit is relativelysmall, when the matrix B with a large amount of data is sent to thebasic unit at one time, then a larger register space of the basic unitfor storing the data of the matrix B will be needed. Since there are alarge number of the basic units in the processing device, an increase ofthe register space of each of the basic units will inevitably increasethe cost of the processing device. Therefore, in this case, thebroadcast data block is broadcasted to the basic units in multipletimes, such that the basic unit only needs to store a part of the dataof the broadcast data block each time, thereby reducing the cost of theprocessing device.

It should be noted that, the method for distributing multiple basic datablocks to multiple basic units at S203, may also adopt the method A orthe method B. The only difference is that the transmission method isunicast and the transmitted data is the multiple basic data blocks.

Operations at S204 may be implemented as follows.

When the method A is adopted to broadcast the broadcast data block andto distribute basic data block (as illustrated in FIG. 4a ), the basicunit may perform inner-product operations to the basic data block andthe broadcast data block to obtain an inner-product processing result.That is to perform an inner-product operation for one line at one time,and to transmit the inner-product processing result (one kind of theoperation results) to the main unit, and the main unit accumulates theinner-product processing result. In practical applications, the basicunit may accumulate the inner-product processing result and transmit anaccumulated result (another kind of the operation results) to the mainunit. The above-mentioned method can reduce the amount of datatransmission between the main unit and the basic unit, thereby improvingcalculation speed.

When the method B is adopted to broadcast the broadcast data block, thebasic unit may perform an inner-product operation for a basic data blockand a broadcast data sub-block to obtain an operation sub-result whenreceiving the broadcast data sub-block. The operation sub-result may besent to the main unit by the basic unit, and the main unit performsaccumulation operation for the processing result. In another embodiment,when the basic unit receives n basic data blocks, n operationsub-results may be obtained by multiplexing the broadcast data block toperform inner-product operation with the n basic data blocks. The basicunit may send the n operation sub-results to the main unit, and the mainunit may perform accumulation operation for the n processing results.The above accumulation operation can also be performed by the basicunit.

In the above case, the amount of data of the broadcast data block isgenerally very large, as well as the distribution data block. Theprocessing device is a kind of a hardware configuration, the basic unitsof the processing device may be innumerable in theory. However, inpractice, the number of the basic units may be generally several tens,which is limited and may change (such as increase) constantly withtechnology development. Therefore, as for the matrix multiplicationoperations in the neural network, the matrix A may have thousands ofrows, and the matrix B may also have thousands of columns, such that itis impossible to transmit the matrix B to the basic unit at one time.Accordingly, an exemplary method may be performed as follows. A part ofthe data of the matrix B (for example, the first five columns of thematrix B), may be broadcast to the basic units at each time. A similarexemplary method may be adopted for the matrix A. The basic unit mayperform an inner-product sub-operation each time, and then, a result ofthe inner-product sub-operation can be stored in the register, and afterall the inner-product operations of the row are executed, an operationresult may be obtained by performing an accumulation operation for allresults of the inner-product operations of the row. The operation resultobtained may be sent to the main unit, thereby improving calculationspeed.

Referring to FIG. 3, a method for performing operations in a neuralnetwork is provided. The embodiments of the present disclosure describea matrix multiplication of a matrix A and a matrix B as an example. Thematrix multiplication of the matrix A and the matrix B is illustrated inFIG. 2b . For convenience of illustration, the calculation method of theneural network illustrated in FIG. 3 is performed in the processingdevice illustrated in FIG. 1b . As illustrated in FIG. 1b , theprocessing device is provided with 16 basic units. For convenience ofdescription and distribution, the value of M as illustrated in FIG. 4ais 32, the value of N is 15, and the value of L is 20. It should beunderstood that the processing device may have any number of basicunits. The method illustrated in FIG. 3 may include the following.

At S301, the main unit may receive the matrix A, the matrix B, and amultiplication operation instruction for the matrix A and the matrix B.

At S302, the main unit may determine that the matrix B is implemented asa broadcast data block and the matrix B is implemented as a distributiondata block according to the multiplication operation instruction. Thematrix A is split into 32 basic data blocks, and each of the 32 basicdata blocks is a row of data of the matrix A.

At S303, the main unit may equally distribute the 32 basic data blocksto the 16 basic units, that is, each basic unit receives two basic datablocks. It should be noted that, the basic data blocks may bedistributed non-repetitively in an arbitrary order.

The basic data blocks at S303 may be distributed in other manners. Forexample, when the basic data blocks cannot be distributed equally toeach basic unit, then the basic data blocks may be distributed to eachbasic unit unequally. A data block that cannot be equally distributed tothe basic units, may be first split into several parts, and then theseveral parts may be equally distributed to the basic units. The mannerin which the basic data blocks are distributed to multiple basic unitsis not limited in the embodiments of the present disclosure.

At S304, the main unit may select the first few columns of the matrix B(such as the first five columns, for the convenience of description, thefollowing takes multiple groups of five columns of the matrix B as anexample), and broadcast data of the first five columns of the matrix Bto the 16 basic units.

At S305, the 16 basic units may multiplex the data of the first fivecolumns twice to perform inner-product operations with the two basicdata blocks, and perform an accumulation operation to obtain 32*5first-processing results, and then send the 32*5 first-processingresults to the main unit.

At S306, the main unit may select data of the middle five columns of thematrix B, and broadcast the data of the middle five columns of thematrix B to 16 basic units.

At S307, the 16 basic units may multiplex the data of the middle fivecolumns twice to perform inner-product operations with the two basicdata blocks, and perform an accumulation operation to obtain 32*5middle-processing results, and then send the 32*5 middle-processingresults to the main unit.

At S308, the main unit may select data of the last five columns of thematrix B, and broadcast the data of the last five columns of the matrixB to the 16 basic units.

At S309, the 16 basic units may multiplex the data of the last 5 columnstwice to perform inner-product operations with the two basic datablocks, and perform an accumulation operation to obtain 32*5last-processing results, and then send 32*5 last-processing results tothe main unit.

At S310, the main unit may combine the 32*5 first-processing results,the 32*5 middle-processing results, and the 32*5 last-processing resultsin an order from the first to the last to obtain a 32*15 matrix C. Thematrix C is an instruction result of the multiplication operationinstruction A*B.

It should be noted that, in this embodiment, the 15 columns of thematrix B are exemplarily split into the first five columns, the middlefive columns, and the last five columns. In other embodiments, thematrix B can also be flexibly split according to specific conditions.

In the example of FIG. 4b , the matrix A is split into 32 basic datablocks, and then the matrix B may be broadcast in batches, such that thebasic unit can obtain instruction results in batches. Since aninner-product operation is split and calculated by 16 basics units, thecalculation time duration can be greatly reduced, which has advantagesof short calculation time and low energy consumption.

In some embodiments, a processing device is provided by the disclosure.As shown in FIG. 1a and FIG. 1b , the processing device includes a mainunit and a plurality of basic units. The main unit is a hardware chipunit, and the plurality of basic units are also hardware chip units.

The main unit is configured to perform a set of operations in a neuralnetwork in series and to transmit data to the basic units.

The basic units are configured to perform a set of operations inparallel in the neural network according to the data transmitted by themain unit, and to transmit operation results to the main unit.

The above-mentioned parallel operations may include, but are not limitedto, large-scale and parallelizable operations such as multiplicationoperations between data blocks, convolution operations, and the like.

The above-mentioned operation includes, but is not limited to,accumulation operation, matrix transposition operation, data sortingoperation, and the like.

In one embodiment, the main unit is configured to obtain a data blockto-be-calculated and an operation instruction, to divide the data blockto-be-calculated into a distribution data block and a broadcast datablock according to the operation instruction, to obtain a plurality ofbasic data blocks by splitting the distribution data block, and todistribute the plurality of basic data blocks to the basic units andbroadcast the broadcast data block to the basic units. The basic unitsare configured to obtain operation results by performing inner-productoperations for the basic data blocks and the broadcast data block and tosend the operation results to the main unit. The main unit is furtherconfigured to obtain an instruction result corresponding to the datablock to-be-calculated and the operation instruction by processing theoperation results.

In one embodiment, the processing device further includes a branch unitdisposed between the main unit and at least one basic unit. The branchunit is configured to forward data between the main unit and the atleast one basic unit.

In one embodiment, the main unit is further configured to broadcast thebroadcast data block to multiple basic units by one broadcast.

In one embodiment, the basic units are further configured to obtaininner-product processing results by performing inner-product operationsfor each of the basic data blocks and the broadcast data block, toobtain the operation results by performing accumulation operation foreach of the inner-product processing results respectively, and to sendthe operation results to the main unit.

In one embodiment, the main unit is further configured to obtainaccumulated results by performing accumulation operation for each of theoperation results respectively when the operation results areinner-product processing results, and to obtain the instruction resultby arranging the accumulated results, where the instruction result iscorresponding to the data blocks to-be-calculated and the operationinstruction.

In one embodiment, the main unit is further configured to obtain aplurality of broadcast data sub-blocks by splitting the broadcast datablock and to broadcast the plurality of broadcast data sub-blocks to theplurality of basic units by multiple broadcasts.

In one embodiment, the basic units are further configured to obtaininner-product processing results by performing one inner-productoperation for each of the broadcast data sub-blocks and each of thebasic data blocks, to obtain operation sub-results by performingaccumulation operation for each of the inner-product processing results,and to send the operation sub-results to the main unit.

In one embodiment, the basic unit is configured to obtain n processingsub-results by multiplexing each of the broadcast data sub-blocks ntimes to perform inner-product operation with n basic units, to obtain noperation sub-results by performing accumulation operation for each ofthe n processing sub-results respectively, and to send the n operationsub-results to the main unit, where the n is an integer greater than orequal to two.

According to one embodiment of the present disclosure, an applicationmethod for the processing device illustrated in FIG. 1a is provided. Theapplication method is applicable to perform one or any combination of amatrix-multiplying-matrix operation, a matrix-multiplying-vectoroperation, a convolution operation, or fully connected operation.

In one embodiment, the main unit may further perform neural networkoperations such as a pooling operation, a normalization operation (forexample, a batch normalization and a local response normalization(LPN)), and the like.

According to one embodiment of the present disclosure, a chip isprovided, which includes the processing device illustrated in FIG. 1a orFIG. 1 b.

According to one embodiment of the present disclosure, an intelligentdevice is provided, which includes the above-mentioned chip thatintegrates the processing device illustrated in FIG. 1a or FIG. 1b . Theintelligent device includes, but is not limited to, a smart phone, atablet computer, a personal digital assistant, a smart watch, a smartcamera, a smart television, a smart refrigerator and other smartdevices. The above-mentioned devices are for illustrative purposes only,and the specific embodiments of the present application are not limitedto the specific forms of the above-mentioned devices.

For the matrix multiplication operation, reference can be made to thedescription of the embodiments illustrated in FIGS. 4a-4g , and detailsare not described herein again.

In one embodiment, the processing device perform a fully connectedoperation as follows.

Assuming input data of a fully connected layer is a vector of length L(such as a vector B in FIG. 4a containing a single sample of, that is,data transmitted in a single broadcast), output data of the fullyconnected layer is a vector of length M, and a weight of the fullyconnected layer is an M*L matrix (such as a matrix A in FIG. 4a ). Theweight matrix of the fully connected layer is implemented as the matrixA (i.e., distribution data block), and the input data of the fullyconnected layer is implemented as the vector B (i.e., broadcast datablock). The fully connected operation can be performed according to themethod illustrated in FIG. 2 a.

In another implementation, assume that the input data of the fullyconnected layer is a matrix (that is, input data of the neural networkis multiple samples which are operated together as a batch). The inputdata of the fully connected layer represents N input samples and eachsample is a vector of length L, and then the input data is representedby a L*N matrix such as a matrix B in FIG. 4b containing multiplesamples, and each output of each sample in the fully connected layer isa vector of length M. The output data of the fully connected layer is anM*N matrix, such as a result matrix in FIG. 4a contains multiplesamples, the weight of the fully connected layer is an APT matrix (i.e.,matrix A in FIG. 4a ). In this case, the weight matrix of the fullyconnected layer is implemented as the matrix A (i.e., distribution datablock), and the input data matrix of the fully connected layer isimplemented as the matrix B (i.e., broadcast data block). Alternatively,the weight matrix of the fully connected layer is implemented as thematrix B (i.e., broadcast data block), and the input data matrix of thefully connected layer is implemented as the matrix A (i.e., distributiondata block). The specific operations can be performed according to themethod illustrated in FIG. 2 a.

When the artificial neural network operation is performed by theprocessing device, exemplary input data of a convolutional layer, apooling layer, a regularization layer, and the like in the neuralnetwork are illustrated in FIG. 4d . The regularization layer is alsocalled a normalization layer, such as batch normalization (BN) or localresponse normalization (LRN). For the sake of clarity, thethree-dimensional data block representing each sample is described withC=5, H=10, and W=12 as an example. In practice, the sizes of N, C, H,and W are not limited to those values illustrated in FIG. 4d . Each ofthe three-dimensional data blocks in FIG. 4d represents a samplecorresponding to the input data of a layer. The three dimensions of eachthree-dimensional data block are represented by C, H and W,respectively, and the total number of the three-dimensional data blocksis N.

For the calculations of the above-mentioned neural network layers, whenreceiving the input data, the main unit arranges each sample of theinput data in a certain order through the data rearrangement circuit ofthe main unit, where the order may be arbitrary.

For example, the input data may be arranged in an order that coordinatesof data in the dimension C vary, such as in an order of NHWC, NWHC, andthe like, where C is the dimension of the innermost layer of a datablock, N is the dimension of the outermost layer of the data block, andH and W are the dimensions of the middle layer of the data block. Inthis way, the data in dimension C is arranged adjacently andconsecutively, thereby facilitating an increase of operation parallelismand parallel operations for multiple feature maps.

The following implementations are described for the understanding ofdimensions C, H, and W according to different neural network operations.For a convolution operation and a pooling operation, and W aredimensions in which relevant operation windows slide when performingconvolution and pooling operations. The operation window sliding indimension W is illustrated in FIG. 4e (illustrating a sliding a)and FIG.4f (illustrating a sliding b). The operation window sliding in dimensionH is illustrated in FIG. 4g . The size of the operation window is thesame as the size of a convolution kernel in M convolution kernels. Forexample, as illustrated in FIG. 4c , each of the M convolution kernelsis a 5*3*3 three-dimensional data block, and then the operation windowis also a 5*3*3 three-dimensional data block. For the M convolutionkernels illustrated in FIG. 3c , KH represents the dimension H of inputdata, and KW represents the dimension W of the input data. Gray squaresin FIGS. 4e, 4f, and 4g represent data to be calculated each time theoperation window is slid, and the operation window may be operated tofirst slide in the dimension H and then to slide in dimensionalternatively, the operation window may be operated to first slide indimension W and then to slide in dimension H. Specifically, for theconvolution operation, operations in each position of the operationwindow include performing inner-product operations for the data blocksindicated by the gray squares with the M convolution kernel data blocksillustrated in FIG. 4c respectively, such that one value may be outputby each of the M convolution kernels each time the operation window isslid, that is, there are M values will be output at each position of theoperation window that is, each time the operation window is slid). Forthe pooling operation, operations in each position of the operationwindow include obtaining a maximum value, an average value, or the like,among the data blocks indicated by the gray squares in dimension H anddimension W (that is, 9 data blocks on the same plane of the gray datablock in dimension H and dimension W), that is, there are C values willbe output at each position of the operation window C is anotherdimension in the three-dimensional data block of a single sample otherthan H and W and N represents a total of N samples simultaneouslyperforming the operation in a layer. For the LRN in the regularizationoperation, the dimension C is defined as a dimension along which the LRNoperation selects a continuous data block (i.e., a data block of Y*1*1)each time, where Y in the data block of Y*1*1 is a value of the numberof data selected in the dimension C, the value of Y is less than orequal to the maximum value of the number of data in the dimension C, thefirst “1” represents the number of data selected in the dimension andthe second “1” represents the number of data selected in the dimensionW. That is, when the regularization operation LRN is performed for eachof the three-dimensional data blocks of one sample, each regularizationoperation LRN is performed for a part of the continuous data with thesame W coordinate and H coordinate but different C coordinate. For theregularization operation BN, an average and a variance (or a standarddeviation) of all values that have the same coordinate on dimension C inthe three-dimensional data block of the N samples are calculated.

Each of squares in FIG. 4c to FIG. 4g represents a value, which may alsobe called a weight. The numbers used in the diagram are for illustrativepurposes only. In practice, a dimension value may be any value (forexample, a certain dimensional value is one, in this case thefour-dimensional data block automatically becomes a three-dimensionaldata block. For another example, when the number of samplessimultaneously calculated is one, the input data is a three-dimensionaldata block. For yet another example, when the number of convolutionkernel is one, the convolution kernel data is a three-dimensional datablock). A convolution operation between input data B and convolutionkernel A is performed by the processing device.

A weight (all convolution kernels) of a convolution layer is illustratedin FIG. 4c . The number of convolution kernels is M, and eachconvolution kernel consists of C matrices of KH rows and KW columns, andthe weight of the convolutional layer may be expressed as afour-dimensional data block with four dimensions of M, C, KH and KW. Theinput data of the convolutional layer is a four-dimensional data block,which consists of N three-dimensional data blocks, and each of thethree-dimensional data blocks consists of C characteristic matrices of Hrows and W columns (i.e., a data block with four dimensions of N, C, H,W), as shown in FIG. 4d . A weight of each of the M convolution kernelsis distributed from the main unit to one of K basic unit, and stored inan on-chip buffer and/or register of the basic unit (in this case, the Mconvolution kernels are implemented as distribution data blocks, andeach convolution kernel can be implemented as a basic data block. Ofcourse, in practical applications, the basic data block can also bechanged into a smaller dimension, such as a matrix of a plane in akernel). The specific method of distribution can be implemented asfollows. When the number of the convolution kernels is M and each of theM basic units is distributed with one weight of convolution kernels.When the number of the convolution kernels is M and M>K, each of the Mbasic units is distributed with one or more weights of convolutionkernels. The convolution kernel weight set distributed to the basic unitis denoted by Ai, and there are a total of Mi convolution kernels. Foreach basic unit, such as the i^(th) basic unit, the received convolutionkernel weight Ai distributed by the main unit is stored in registerand/or on-chip buffer of the basic unit. The main unit transmits eachpart of input data (such as data in operation windows illustrated inFIG. 4e , FIG. 4f and FIG. 4g ) to each basic unit in broadcast manner(such as the over-mentioned method A or method B).When broadcasting, theweights of the operation window can be broadcast to all the basic unitsby multiple broadcasts. Specifically, a part of the weights of theoperation window may be broadcasted each time. For example, a matrix ofdata in a plane is broadcasted each time, and taking FIG. 4e as anexample, a KH*KW matrix on plane C can be broadcasted each time. Inpractical applications, first front n rows or first front n columns of aKH*HW matrix on plane C can also be broadcast at one time. The manner inwhich the above partial data is transmitted and the arrangement ofpartial data is not limited by the present disclosure. The input datamay be arranged in an arbitrary dimension order, and then each part ofthe input data is sequentially broadcast to the basic unit. In oneembodiment, the foregoing distribution data (that is, the convolutionkernels), may also be sent in a manner similar to that of the operationwindow of the input data, and details are not described herein again. Inone embodiment, the input data can be arranged in a cycle where thedimension C is in the innermost layer. In this way, the data indimension C is arranged adjacently and consecutively, therebyfacilitating an increase of operation parallelism and paralleloperations for multiple feature maps. In one embodiment, the input datacan be arranged in a dimension order of NHWC or NWHC. Each basic unit,such as the i^(th) basic unit, calculates the inner product of theconvolution kernel in the weight Ai and a corresponding part of thereceived broadcast data (i.e., a part of data in the operation window),where the data of the corresponding part of the weight Ai can be readdirectly from the on-chip buffer, or can be read into the register formultiplexing. In one embodiment, an accumulation operation may beperformed for each of the inner-product processing results of basicunits to obtain operation results, and then the operation results may betransmitted back to the main unit. Alternatively, each of theinner-product processing results of basic units may be transmitted backto the main unit, and then the main unit may perform an accumulationoperation for each of the inner-product processing results. In oneembodiment, a sub-sum obtained by performing the inner-product operationvia each basic unit may be stored and accumulated in the on-chip bufferand/or the register of the basic unit, and then transmitted back to themain unit. In one embodiment, in some cases, a sub-sum obtained byperforming the inner-product operation via each basic unit may be storedand accumulated in the on-chip buffer and/or the register of the basicunit, and then transmitted back to the main unit, in other cases, asub-sum obtained by performing the inner-product operation via eachbasic unit may be directly transmitted to the basic unit and thenaccumulated by the main unit.

A method for implementing a basic linear algebra subprograms (BLAS)function by the processing device is provided as follows.

General matrix multiply (GEMM) calculation refers to the matrixmultiplication operation in the BLAS library, which is normallyexpressed as C=alpha*op(A)*op(B)+beta*C, where A and B are two inputmatrices, C is a output matrix, alpha and beta are scalars, and oprepresents an operation for matrix A or B. In addition, there will besome supplementary integers as parameters to explain the width andheight of the matrices A and B.

Operations for implementing a GEMM calculation by the processing deviceare described as follows.

The main unit of the processing device performs corresponding opoperations on matrix A and matrix B respectively. The op operation maybe a matrix transposition or other operations, such as nonlinearfunction operation, pooling operation, and so on. The matrix opoperation is implemented by the vector operation function of the mainunit. The op of a matrix may be null, it indicates that the main unitperforms no operation on the matrix.

A matrix multiplication of op(A) and op(B) is completed by employing themethod illustrated in FIG. 2 a.

Each value of the results of op(A)*op(B) is multiplied by alpha, byemploying the vector operation function of the main unit.

Data at corresponding positions in op(A)*op(B) and beta*C are added, byemploying the vector operation function of the main unit.

General matrix-vector (GEMV) calculation refers to thematrix-multiplying-vector operation in the BLAS library, which isnormally expressed as C=alpha*op(A)*B+beta*C, where A is an inputmatrix, B is an input vector, C is a output matrix, alpha and beta arescalars, and op represents an operation for matrix A.

Operations for implementing a GEMV calculation by the processing deviceare described as follows.

The main unit of the processing device performs a corresponding opoperation on matrix A. The processing device completes thematrix-multiplying-vector operation of the matrix op(A) and the vectorB. Each value of the results of op(A)*B is multiplied by alpha, byemploying the vector operation function of the main unit. Data atcorresponding positions in op(A)*B and beta*C are added, by employingthe vector operation function of the main unit.

A method for implementing an activation function operation is providedas follows.

An activation function operation generally refers to performing anonlinear operation for each data of a data block (such as a vector or amulti-dimensional matrix). For example, the activation function may beexpressed as y=max(m, x), where x is an input value, v is an outputvalue, and m is a constant. For example, the activation function may beexpressed as y=tanh(x), where x is an input value and y is an outputvalue. For another example, the activation function can be expressed asy=sigmoid(x), where x is an input value and y is an output value. Foryet another example, the activation function may be a piecewise linearfunction. For still yet another example, the activation function can beany function that outputs a value when a value is inputted.

In a process for implementing an activation function operation, theprocessing device may input a vector to calculate an activation vectorcorresponding to the vector, by employing the vector operation functionof the main unit. The main unit performs an activation functionoperation on each value of an input vector to obtain an output value,when the input of the activation function is a value, the output is alsoa. value, and output the output value into the corresponding position ofan output vector.

The above-mentioned input vector may be obtained from, but not limitedto, external data of the processing device, and calculation result dataof the basic unit forwarded by the branch unit of the processing device.

The above-mentioned calculation result data may specifically be anoperation result of a matrix-multiplying-vector operation. Thecalculation result data may further be an operation result of amatrix-multiplying-matrix operation. The calculation result data may bean operation result of an add-offset operation implemented by the mainunit.

A method for implementing an add-offset operation by the main unit isprovided as follows.

Two vectors or two matrices can be added by the main unit. A vector canbe added with each row or each columns of a matrix by the main unit

For example, the above-mentioned matrix may be a result of amatrix-multiplying-matrix operation performed by the processing device.The matrix may be a result of a matrix-multiplying-vector operationperformed by the processing device. The matrix may be determined fromexternal data received by the processing device.

The above-mentioned input data and the calculation result data aremerely illustrative. In practical applications, data of other types orsources may also be applicable. The specific embodiments of the presentdisclosure do not limit the source and expression manner of theabove-mentioned data.

It is to be noted that, for the sake of simplicity, the foregoing methodembodiments are described as a series of action combinations, however,it will be appreciated by those skilled in the art that the presentdisclosure is not limited by the sequence of actions described.According to the present disclosure, certain steps or operations may beperformed in other order or simultaneously. Besides, it will beappreciated by those skilled in the art that the embodiments describedin the specification are exemplary embodiments and the actions andmodules involved are not necessarily essential to the presentdisclosure.

In the foregoing embodiments, the description of each embodiment has itsown emphasis. For the parts not described in detail in one embodiment,reference may be made to related descriptions in other embodiments.

In the embodiments of the disclosure, the apparatus disclosed inembodiments provided herein may be implemented in other manners. Forexample, the device/apparatus embodiments described above are merelyillustrative; for instance, the division of the unit is only a logicalfunction division and there can be other manners of division duringactual implementations, for example, multiple units or components may becombined or may be integrated into another system, or some features maybe ignored, omitted, or not performed. In addition, coupling orcommunication connection between each illustrated or discussed componentmay be direct coupling or communication connection, or may be indirectcoupling or communication among devices or units via some interfaces,and may be electrical connection, mechanical connection, or other formsof connection.

In addition, the functional units in various embodiments of the presentdisclosure may be integrated into one processing unit, or each unit maybe physically present, or two or more units may be integrated into oneunit. The above-mentioned integrated unit/module can be implemented inthe form of hardware. For example, the hardware can be a circuit,including a digital circuit, an analog circuit, and the like. Physicalimplementations of hardware structures include, but are not limited to,physical elements. The physical elements include, but not limited to,transistors, memristors, and the like. The calculating modules in acalculating device can be any suitable hardware processor, such as aCPU, a GPU, a field programmable gate array (FPGA), a digital signalprocessor (DSP), an application specific integrated circuit (ASIC), andthe like. The storage unit may be any suitable magnetic storage mediumor magneto-optical storage medium such as a resistive random accessmemory (RRAM), a dynamic random access memory (DRAM), a static randomaccess memory (SRAM), an enhanced DRAM (EDRAM), a high bandwidth memory(HBM), a hybrid memory cube (HMC), and the like.

The units described may or may not be physically separated, that is,they may be in the same place or may be distributed to multiple networkelements. All or part of the units may be selected according to actualneeds to achieve the purpose of the technical solutions of theembodiments.

The embodiments of the present disclosure have been described in detailabove, and the principles and implementations of the present disclosureare described in the specific examples. The description of the aboveembodiments is merely used to facilitate understanding the method andcore ideas of the present disclosure. For a person of ordinary skill inthe art, in light of the present disclosure, there may be changes in thespecific implementation and application scope. The contents of thepresent specification should not be construed as limiting thedisclosure.

What is claimed is:
 1. A pooling operation method performed by aprocessing device, comprising: receiving, by the processing device,input data, wherein the input data is four-dimensional data arranged indimensions N, C, H, and W, wherein dimension C is between an outermostlayer and an innermost layer of the input data; rearranging, by theprocessing device, the input data such that dimension C becomes theinnermost layer of the input data; and performing, by the processingdevice, a pooling operation on the input data.
 2. The pooling operationmethod of claim 1, wherein the input data is in a dimension order ofNCHM, wherein rearranging the input data further includes: changing thedimension order of the input data to NHWC or NWHC.
 3. The poolingoperation method of claim 1, wherein the chip device includes a mainprocessing circuit and a plurality of basic processing circuits, andwherein performing the pooling operation on the input data furtherincludes: obtaining, by the main processing circuit, data to becalculated by sliding an operation window in dimensions H and W of therearranged input data; and performing the pooling operation on the datato be calculated at each position of the operation window as it slides.4. The pooling operation method of claim 3, wherein obtaining the datato be calculated further includes: sliding the operation window in thedimension W after sliding the operation window in the dimension H, orsliding the operation window in the dimension H after sliding theoperation window in the dimension W.
 5. The pooling operation method ofclaim 1, wherein the pooling operation is a maximum value operation oran average value operation.
 6. The pooling operation method of claim 3,wherein performing the pooling operation on the data to be calculatedoutputs C values at each position of the operation window.
 7. Thepooling operation method of claim 3, further comprising performing, bythe main processing circuit and the plurality of basic processingcircuits collaboratively, a convolution operation between the input dataand a weight.
 8. The pooling operation method of claim 7, wherein theweight comprises a plurality of convolution kernels, wherein the size ofthe operation window is the same as the size of each convolution kernel.9. The pooling operation method of claim 3, wherein the processingdevice further includes branch processing circuits configured to connectthe main processing circuit to the plurality of basic processingcircuits, and the method further includes: transmitting, by the branchprocessing circuits, data among the main processing circuit and theplurality of basic processing circuits.
 10. The pooling operation methodof claim 3, wherein the main processing circuit includes one or anycombination of a vector arithmetic unit circuit, an arithmetic logicunit (ALU) circuit, an accumulator circuit, a matrix transpositioncircuit, a direct memory access (DMA) circuit, and a data rearrangementcircuit wherein each of the basic processing circuits includes one orboth of an inner-product arithmetic unit circuit and an accumulatorcircuit.
 11. A processing device, comprising a main processing circuitand a plurality of basic processing circuits, wherein the mainprocessing circuit is configured to: receive input data, wherein theinput data is four-dimensional data arranged in dimensions N, C, H, andW, wherein dimension C is between an outermost layer and an innermostlayer of the input data; rearrange the input data such that dimension Cbecomes the innermost layer; and perform a pooling operation on therearranged input data.
 12. The processing device of claim 11, whereinthe input data is in a dimension order of NCHM, wherein the mainprocessing circuit is configured to change the dimension order of theinput data to NHWC or NWHC.
 13. The processing device of claim 11,wherein to perform the pooling operation, the main processing circuit isfurther configured to: obtain data to be calculated by sliding anoperation window in dimensions H and W of the rearranged input data; andperform the pooling operation on the data to be calculated at eachposition of the operation window as it slides.
 14. The processing deviceof claim 13, wherein the data to be calculated is obtained by: slidingthe operation window in the dimension W after sliding the operationwindow in the dimension H; or sliding the operation window in thedimension H after sliding the operation window in the dimension W. 15.The processing device of claim 13, wherein the pooling operation is amaximum value operation or an average value operation.
 16. Theprocessing device of claim 13, wherein by performing the poolingoperation on the data to be calculated, the main processing circuitoutputs C values at each position of the operation window.
 17. Theprocessing device of claim 13, wherein the main processing circuit andthe plurality of basic processing circuits are configured tocollaboratively perform a convolution operation between the input dataand a weight.
 18. The processing device of claim 17, wherein the weightcomprises a plurality of convolution kernels, wherein the size of theoperation window is the same as the size of each convolution kernel. 19.The processing device of claim 11, further comprising branch processingcircuits configured to connect the main processing circuit and theplurality of basic processing circuits, wherein the branch processingcircuits are configured to transmit data among the main processingcircuit and the plurality of basic processing circuits.
 20. Theprocessing device of claim 11, wherein the main processing circuitincludes one or any combination of a vector arithmetic unit circuit, anarithmetic logic unit (ALU) circuit, an accumulator circuit, a matrixtransposition circuit, a. direct memory access (DMA) circuit and a datarearrangement circuit, and each of the basic processing circuitsincludes one or both of an inner-product arithmetic unit circuit and anaccumulator circuit.